package com.dd.ms.auth.utils.converter;

import com.dd.ms.auth.pojo.dto.RolePermissionDTO;
import com.dd.ms.auth.vo.PermissionVO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/7/10 9:53
 * @Description 类功能作用说明
 */
public class PermissionConverter {

    public static PermissionVO toVO(RolePermissionDTO permissionDTO) {
        if (permissionDTO == null) {
            return null;
        }
        PermissionVO permissionVO = new PermissionVO();
        BeanUtils.copyProperties(permissionDTO, permissionVO);
        return permissionVO;
    }

    public static List<PermissionVO> toVO(List<RolePermissionDTO> permissionDTOList) {
        if (permissionDTOList == null) {
            return null;
        }
        List<PermissionVO> permissionVOList = new ArrayList<>();
        permissionDTOList.forEach(permissionDTO -> {permissionVOList.add(toVO(permissionDTO));});
        return permissionVOList;
    }
}
